package com.wechat.core.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>label:</p>
 * <p>description:</p>
 * <p>company:</p>
 * <p></p>
 *
 * @author <a href="kingyon@kingyon.com">Peng yi</a>
 * @date 2018/7/25
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode
public class Entity<T extends Model<?>> extends Model<T> implements Serializable {

    private static final long serialVersionUID = 739668778715426460L;

    @TableId(value = "id", type = IdType.ID_WORKER)
    @ApiModelProperty("主键")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @ApiModelProperty("删除状态（0，正常，1已删除）")
    private Integer delFlag;

    @ApiModelProperty("创建时间")
    private Date createTime;

    @ApiModelProperty("更新时间")
    private Date updateTime;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Entity<?> entity = (Entity<?>) o;
        return entity.getId().equals(this.id);
    }
}
